<%@ page language="java" import="java.util.*" 
import="software.Use_user"
pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.STYLE1 {font-size: 12px}
.STYLE4 {
	font-size: 12px;
	color: #1F4A65;
	font-weight: bold;
}

a:link {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;

}
a:visited {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;
}
a:hover {
	font-size: 12px;
	color: #FF0000;
	text-decoration: underline;
}
a:active {
	font-size: 12px;
	color: #FF0000;
	text-decoration: none;
}
.STYLE7 {font-size: 12}

-->
</style>

<script>
var  highlightcolor='#eafcd5';
//此处clickcolor只能用win系统颜色代码才能成功,如果用#xxxxxx的代码就不行,还没搞清楚为什么:(
var  clickcolor='#51b2f6';
function  changeto(){
source=event.srcElement;
if  (source.tagName=="TR"||source.tagName=="TABLE")
return;
while(source.tagName!="TD")
source=source.parentElement;
source=source.parentElement;
cs  =  source.children;
//alert(cs.length);
if  (cs[1].style.backgroundColor!=highlightcolor&&source.id!="nc"&&cs[1].style.backgroundColor!=clickcolor)
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor=highlightcolor;
}
}
function  changeback(){
if  (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="nc")
return
if  (event.toElement!=source&&cs[1].style.backgroundColor!=clickcolor)
//source.style.backgroundColor=originalcolor
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor="";
}
}

function  clickto(){
source=event.srcElement;
if  (source.tagName=="TR"||source.tagName=="TABLE")
return;
while(source.tagName!="TD")
source=source.parentElement;
source=source.parentElement;
cs  =  source.children;
//alert(cs.length);
if  (cs[1].style.backgroundColor!=clickcolor&&source.id!="nc")
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor=clickcolor;
}
else
for(i=0;i<cs.length;i++){
	cs[i].style.backgroundColor="";
}
}
function  deletep(id){
    if (confirm("真的要删除吗？"))
    { 
		alert("暂时不支持这功能");
       return true;
     }
    else return false;
}
function openstr(id,name,nick,pwd,email)
{   
	var NICK=nick;
	var ReturnValue=window.showModalDialog("a15.jsp?id="+id+"&name="+name+"&nick="+nick+"&pwd="+pwd+"&email="+email,NICK,"dialogWidth=310px;dialogHeight=250px;status=no");
  	if(ReturnValue.email!="" && ReturnValue.pwd!="")
		window.location.href("manege_users.jsp?action=edit&id="+id+"&nick="+encodeURI(encodeURI(ReturnValue.nick))+"&pwd="+ReturnValue.pwd+"&email="+ReturnValue.email);
	else
		alert("注册邮箱或密码不能为空，修改失败！");
}
function newp()
{   
    ReturnValue=window.showModalDialog("a12.jsp",window,"dialogWidth=310px;dialogHeight=250px;status=no");
   if(ReturnValue.name!="" && ReturnValue.pwd!=""&&ReturnValue.email!="")
		window.location.href("manege_users.jsp?action=new&name="+ReturnValue.name+"&nick="+encodeURI(encodeURI(ReturnValue.nick))+"&pwd="+ReturnValue.pwd+"&email="+ReturnValue.email);
 	else
	 	alert("用户名、密码、注册邮箱不能为空，修改失败！");
}
</script>
</head>

<body>
<%
request.setCharacterEncoding("UTF-8");   
Use_user manegeuser=new Use_user();
String a=request.getParameter("page");
String Action=request.getParameter("action");
String ID=request.getParameter("id");
String Name=request.getParameter("name");
String Nick=new String();
if(request.getParameter("nick")!=null)
Nick=new String(java.net.URLDecoder.decode(new String(request.getParameter("nick").getBytes("ISO-8859-1")),"UTF-8"));
//String Nick=request.getParameter("nick");
String Pwd=request.getParameter("pwd");
String Email=request.getParameter("email");
//  编辑数据
if(Action!=null){
if(Action.equals("edit"))
{	
	int id=0;
	try{
		id=Integer.parseInt(ID);
		manegeuser.setID(id);
		manegeuser.setNickName(Nick);
		manegeuser.setPassword(Pwd);
		manegeuser.setEmail(Email);
		manegeuser.UserList_Edit();
	}catch(Exception e){
	}
}
if(Action.equals("new"))
{	
	manegeuser.setUsername(Name);
	manegeuser.setEmail(Email);
	if(!manegeuser.Che_NameR())
	 out.print("<script>alert('用户名已注册')</script>");
	else if(!manegeuser.Che_EmailR())
	 out.println("<script>alert('邮箱已注册')</script>");
	else
	{
		manegeuser.setNickName(Nick);
		manegeuser.setPassword(Pwd);
		manegeuser.RegisterR();
	}
}
//  删除 数据
if(Action.equals("delete"))
{
	int id=0;
	try{
	id=Integer.parseInt(ID);
	}catch(Exception e){
	}
}}
//  对页数管理
int Page=1;
int Num_Plates=manegeuser.getNumUser();
int TotalPage=(Num_Plates-1)/20+1; // 每页最对显示20条记录
try{
	Page=Integer.parseInt(a);
}catch(Exception e){
}
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="30"><img src="tab/images/tab_03.gif" width="15" height="30" /></td>
        <td width="1101" background="tab/images/tab_05.gif"><img src="tab/images/311.gif" width="16" height="16" /> <span class="STYLE4">用户信息列表</span></td>
        <td width="281" background="tab/images/tab_05.gif">
		<table width="88" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td class="STYLE1"><div align="center"><a href="#"><img src="tab/images/001.gif" width="14" height="14" /></a></div></td>
                    <td class="STYLE1"><div align="center"><a href="#" onClick="return newp()">新增</a></div></td>
                  </tr>
            </table>
		</td>
        <td width="14"><img src="tab/images/tab_07.gif" width="14" height="30" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="9" background="tab/images/tab_12.gif">&nbsp;</td>
        <td bgcolor="#f3ffe3"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#c0de98" onMouseOver="changeto()"  onmouseout="changeback()">
          <tr>
            <td width="2%" rowspan="2" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">序号</div>              </td>
            <td width="10%" rowspan="2" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">头像</div></td>
            <td width="24%" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">用户名</div></td>
            <td width="16%" height="26" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">昵称</div></td>
            <td width="30%" height="26" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">Email</div>              </td>
            <td width="18%" height="26" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">编辑</div></td>
            </tr>
		   <tr>
            <td width="24%" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">密码</div></td>
            <td height="26" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">积分</div></td>
            <td width="30%" height="26" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">注册时间</div>              </td>
            <td height="26" background="tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">删除</div></td>
            </tr>
    <%
		manegeuser.Read_UserList(Page);//  读取第 Page 页
   		for(int i=0;i<manegeuser.getNumpage();i++){
   		manegeuser.NextUser();
    %>
          <tr>
            <td rowspan="2" bgcolor="#FFFFFF" class="STYLE2"><div align="center" class="STYLE2 STYLE1"><%=i+Page*20-19 %></div>              <div align="center" class="STYLE2 STYLE1"></div></td>
            <td rowspan="2" bgcolor="#FFFFFF" class="STYLE2"><div align="center"><img src="../Photo/<%=manegeuser.getPhoto()%>" width="30" height="30" /> </div> </td>
            <td height="18" bgcolor="#FFFFFF" class="STYLE2"><div align="center" class="STYLE2 STYLE1"><%=manegeuser.getName() %></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><%=manegeuser.getNickName() %></div>              <div align="center" class="STYLE2 STYLE1"></div>              <div align="center" class="STYLE2 STYLE1"></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><%=manegeuser.getEmail() %></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center"><span class="STYLE2"><img src="tab/images/037.gif" width="9" height="9" /></span><span class="STYLE1"> [</span><a href="#" onClick="return openstr(<%=manegeuser.getId()%>,'<%=manegeuser.getName()%>','<%=manegeuser.getNickName()%>','<%=manegeuser.getPassword()%>','<%=manegeuser.getEmail()%>')">编辑</a><span class="STYLE1">]</span></div></td>
            </tr>
          <tr>
            <td height="18" bgcolor="#FFFFFF" class="STYLE2"><div align="center" class="STYLE2 STYLE1"><%=manegeuser.getPassword()%></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><%=manegeuser.getIntegral() %></div>             </td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><%=manegeuser.getTimeR() %></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center"><span class="STYLE2"><img src="tab/images/010.gif" width="9" height="9" /></span><span class="STYLE2"> </span><span class="STYLE1" >[</span><a href="#" onClick="return deletep()">删除</a><span class="STYLE1">]</span></div></td>
            </tr>
        <%
       	 }
         %>
        </table></td>
        <td width="9" background="tab/images/tab_16.gif">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="29"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="29"><img src="tab/images/tab_20.gif" width="15" height="29" /></td>
        <td background="tab/images/tab_21.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="25%" height="29" nowrap="nowrap"><span class="STYLE1">共<%=Num_Plates %>条纪录，当前<%=Page %>/<%=TotalPage %>页，每页20纪录</span></td>
            <td width="75%" valign="top" class="STYLE1"><div align="right">
              <table width="352" height="20" border="0" cellpadding="0" cellspacing="0">
                <tr>
					<%
					if(Page!=1) {
					%>
					 <td width="62" height="22" valign="middle"><div align="right"><img src="tab/images/first.gif" width="37" height="15" /></div></td>
                 	 <td width="50" height="22" valign="middle"><div align="right"><img src="tab/images/back.gif" width="43" height="15" /></div></td>
                 	<%
					 }
					if(Page!=TotalPage){
					%>
					<td width="54" height="22" valign="middle"><div align="right"><img src="tab/images/next.gif" width="43" height="15" /></div></td>
                 	<td width="49" height="22" valign="middle"><div align="right"><img src="tab/images/last.gif" width="37" height="15" /></div></td>
                  <%
					 } 
			      %>	
                   </tr>
              </table>
            </div></td>
          </tr>
        </table></td>
        <td width="14"><img src="tab/images/tab_22.gif" width="14" height="29" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
